from django.conf import settings
from django.contrib import admin
# from django.views.generic import TemplateView
from django.views.static import serve
from django.urls import re_path, include

from rest_framework.documentation import include_docs_urls


API_TITLE = 'API Documents'
API_DESCRIPTION = 'API Information'

urlpatterns = [
    re_path(r'^ht/', admin.site.urls),
    re_path(r'^docs/', include_docs_urls(title=API_TITLE, description=API_DESCRIPTION)),
    re_path(r'^api-auth/', include('rest_framework.urls')),
]

if settings.STATIC_ROOT and settings.STATIC_URL:
    urlpatterns.append(re_path(
        r'^{0}(?P<path>.*)$'.format(settings.STATIC_URL[1:]),
        serve, {'document_root': settings.STATIC_ROOT}, name='static'))

if settings.MEDIA_ROOT and settings.MEDIA_URL:
    urlpatterns.append(re_path(
        r'^{0}(?P<path>.*)$'.format(settings.MEDIA_URL[1:]),
        serve, {'document_root': settings.MEDIA_ROOT}, name='media'))

if 'approval' in settings.INSTALLED_APPS:
    urlpatterns.append(re_path(r'^api/approval/', include('approval.urls_api', namespace='api_approval')))
    urlpatterns.append(re_path(r'^page/approval/', include('approval.urls', namespace='approval')))

if 'django_nyt.apps.DjangoNytConfig' in settings.INSTALLED_APPS:
    urlpatterns.append(re_path(r'^notifications/', include('django_nyt.urls')))

if 'wiki.apps.WikiConfig' in settings.INSTALLED_APPS:
    urlpatterns.append(re_path(r'^wiki/', include('wiki.urls')))

if 'analysis' in settings.INSTALLED_APPS:
    urlpatterns.append(re_path(r'^page/analysis/', include('analysis.urls')))

if 'sop' in settings.INSTALLED_APPS:
    urlpatterns.append(re_path(r'^page/sop/', include('sop.urls')))


urlpatterns.append(re_path(r'^api/', include('oa.urls_api', namespace='api_oa')))
urlpatterns.append(re_path(r'^page/', include('oa.urls', namespace='page')))
